package com.manor.dynamic.activity;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.ConvertUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.tencent.rtmp.TXVodPlayer;
import com.tencent.rtmp.ui.TXCloudVideoView;

import org.greenrobot.eventbus.EventBus;

import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.manor.dynamic.R;
import com.manor.common.CommonAppConfig;
import com.manor.common.Constants;
import com.manor.common.activity.AbsActivity;
import com.manor.common.http.HttpCallback;
import com.manor.common.http.PitUtil;
import com.manor.common.interfaces.CommonCallback;
import com.manor.common.utils.ClickUtil;
import com.manor.common.utils.DialogUitl;
import com.manor.common.utils.DownloadUtil;
import com.manor.common.utils.KLog;
import com.manor.common.utils.L;
import com.manor.common.utils.MD5Util;
import com.manor.common.utils.RouteUtil;
import com.manor.common.utils.ScreenDimenUtil;
import com.manor.common.utils.ToastUtil;
import com.manor.common.utils.WordUtil;
import com.manor.dynamic.adapter.NewCirclePopAdapter;
import com.manor.dynamic.bean.CommunityDynamicBean;
import com.manor.dynamic.custorm.VideoPlayView;
import com.manor.dynamic.dialog.DynamicLookImgDialogFragment;
import com.manor.dynamic.event.DynamicDelEvent;
import com.manor.dynamic.event.DynamicLikeEvent;
import com.manor.dynamic.http.DynamicHttpConsts;
import com.manor.dynamic.http.DynamicHttpUtil;
import com.manor.dynamic.inter.VoicePlayCallBack;
import com.manor.dynamic.views.ViewSizeChangeAnimation;
import com.manor.im.utils.VoiceMediaPlayerUtil;

/**
 * baseactivity
 * 视频放大跳转用
 * Created by debug on 2019/7/24.
 */

public abstract class AbsDynamicActivity extends AbsActivity {
    //视频
    protected ViewGroup mCurContainer;
    protected FrameLayout mOriginContainer;
    protected VideoPlayView mPlayView;
    //列表语言
    private VoiceMediaPlayerUtil mVoiceMediaPlayerUtil;
    protected DownloadUtil mDownloadUtil;
    protected VoicePlayCallBack mVoicePlayCallBack;
    private Handler mHandler;
    protected int mSumVoiceTime;
    protected int mPlayVoiceTime;
    protected TextView mTvVoiceTime;
    int mScreenHeight;
    int mScreenWidth;

    @Override
    protected void main() {
        super.main();
        mCurContainer = findViewById(R.id.play_container);
        mScreenHeight = ScreenDimenUtil.getInstance().getScreenHeight();
        mScreenWidth = ScreenDimenUtil.getInstance().getScreenWdith();
        //        mCurContainer.setClickable(false);
    }

    //点赞
    public void addLike(final CommunityDynamicBean dynamicBean) {
        if (dynamicBean.getUid().equals(CommonAppConfig.getInstance().getUid())) {
            ToastUtil.show(WordUtil.getString(R.string.video_comment_cannot_self));
            return;
        }
        DynamicHttpUtil.addLike(dynamicBean.getId(), new HttpCallback() {
            @Override
            public void onSuccess(int code, String msg, String info) {
                if (code == 0) {
                    String data = PitUtil.strGetFirst(info);
                    JSONObject obj = JSON.parseObject(data);
                    EventBus.getDefault().post(new DynamicLikeEvent(dynamicBean.getId(), obj.getIntValue("islike"), obj.getString("nums")));
                } else {
                    ToastUtil.show(msg);
                }
            }
        });
    }

    //删除动态
    public void delDynamic(final CommunityDynamicBean dynamicBean) {
        DynamicHttpUtil.delDynamic(dynamicBean.getId(), new HttpCallback() {
            @Override
            public void onSuccess(int code, String msg, String info) {
                if (code == 0) {
                    EventBus.getDefault().post(new DynamicDelEvent(dynamicBean.getId()));
                }
                ToastUtil.show(msg);
            }
        });
    }

    //设置 举报和删除
    public void setting(final CommunityDynamicBean dynamicBean) {
        Integer[] integers;
        if (dynamicBean.getUid().equals(CommonAppConfig.getInstance().getUid())) {
            integers = new Integer[]{R.string.del_dynamic_tip};
        } else {
            integers = new Integer[]{R.string.report};
        }
        DialogUitl.showStringArrayDialog(mContext, integers, new DialogUitl.StringArrayDialogCallback() {
            @Override
            public void onItemClick(String text, int tag) {
                if (tag == R.string.report) {
                    RouteUtil.forwardReport(2, dynamicBean.getId());
                    //DynamicReportActivity.forward(mContext, dynamicBean.getId());
                } else if (tag == R.string.del_dynamic_tip) {
                    DialogUitl.showSimpleDialog3(mContext, WordUtil.getString(R.string.del_dynamic_tip2), "", WordUtil.getString(R.string.delete), new DialogUitl.SimpleCallback() {
                        @Override
                        public void onConfirmClick(Dialog dialog, String content) {
                            delDynamic(dynamicBean);
                        }
                    });
                }
            }
        });
    }

    //查看图片
    public void lookImgs(ArrayList<String> list, int selectPos) {
        DynamicLookImgDialogFragment dynamicImgsDialogFragment = new DynamicLookImgDialogFragment();
        Bundle bundle = new Bundle();
        bundle.putStringArrayList(Constants.DYNAMIC_IMG_LIST, list);
        bundle.putInt(Constants.DYNAMIC_IMG_CUR_POS, selectPos);
        bundle.putString(Constants.DYNAMIC_UID, "");
        dynamicImgsDialogFragment.setArguments(bundle);
        dynamicImgsDialogFragment.show(getSupportFragmentManager(), "LookDynamicImgsDialogFragment");
    }

    //查看图片
    public void lookImgs(ArrayList<String> list, int selectPos, CommonCallback<Boolean> commonCallback) {
        DynamicLookImgDialogFragment dynamicImgsDialogFragment = new DynamicLookImgDialogFragment();
        Bundle bundle = new Bundle();
        bundle.putStringArrayList(Constants.DYNAMIC_IMG_LIST, list);
        bundle.putInt(Constants.DYNAMIC_IMG_CUR_POS, selectPos);
        bundle.putString(Constants.DYNAMIC_UID, "");
        dynamicImgsDialogFragment.setArguments(bundle);
        dynamicImgsDialogFragment.setCommonCallback(commonCallback);
        dynamicImgsDialogFragment.show(getSupportFragmentManager(), "LookDynamicImgsDialogFragment");
    }

    ViewGroup viewGroup;
    View myVideGroup;

    //视频放大播
    public FrameLayout addPlayerGroup(final FrameLayout container, final View videoGroup, final VideoPlayView playView) {
        mOriginContainer = container;
        mPlayView = playView;
        myVideGroup = videoGroup;
        viewGroup = (ViewGroup) videoGroup.getParent();
        if (viewGroup != null) {
            ((ViewGroup) viewGroup).removeView(videoGroup);
        }
        playView.setVideoSize(true);
        mCurContainer.addView(videoGroup);
        mCurContainer.setClickable(true);
        playView.resizeVideo(true);
        playView.forceResumePlay();
        videoGroup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                viewGroup = (ViewGroup) videoGroup.getParent();
                if (viewGroup != null) {
                    viewGroup.removeView(videoGroup);

                }
                playView.resizeVideo(false);
                mCurContainer.setClickable(false);
                container.addView(videoGroup);
                videoGroup.setClickable(false);
                mPlayView.setVideoSize(false);
                //                container.setOnClickListener(new View.OnClickListener() {
                //                    @Override
                //                    public void onClick(View v) {
                //                        addPlayerGroup(container,videoGroup,playView,mDynamicVideoViewContainer);
                //                    }
                //                });

            }
        });
        return container;
    }

    private TXVodPlayer mPlayer;
    private TXCloudVideoView mVideoView;
    public static boolean isOnclick = true;

    //动态视频放大
    public FrameLayout addPlayerGroups(final FrameLayout container, final View videoGroup, final TXCloudVideoView mVideoView, ImageView img, int w, int h) {
        if (ClickUtil.canClick(600)) {
            isOnclick = true;
            mOriginContainer = container;
            int[] location = new int[2];
            videoGroup.getLocationOnScreen(location);
            int x = location[0];
            int y = location[1];
            this.mVideoView = mVideoView;
            mPlayer = new TXVodPlayer(AbsDynamicActivity.this);
            myVideGroup = videoGroup;
            viewGroup = (ViewGroup) videoGroup.getParent();
            if (viewGroup != null) {
                ((ViewGroup) viewGroup).removeView(videoGroup);
            }


            //        FrameLayout.LayoutParams param = (FrameLayout.LayoutParams) videoGroup.getLayoutParams();
            //        param.width = mScreenWidth;
            //        param.height = mScreenHeight+ Utils.dip2px(this, 25f);
            //        param.gravity = Gravity.CENTER;
            //        videoGroup.setLayoutParams(param);

            //        Animation animationa = new ViewSizeChangeAnimation(videoGroup, mScreenHeight+ Utils.dip2px(this, 25f),mScreenWidth);
            //        animationa.setDuration(500);
            //        videoGroup.startAnimation(animationa);
            //添加背景
            videoGroup.setBackgroundResource(R.color.main_bg);

            //设置视频view的高度
            resizeVideo(w, h, mVideoView);

            //隐藏播放按钮
            img.setVisibility(View.GONE);
            mCurContainer.addView(videoGroup);
            mCurContainer.setClickable(true);
            videoGroup.setClickable(false);

            //放大动画
            videoGroup.setBackgroundResource(R.color.main_bg);
            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(videoGroup.getWidth(), videoGroup.getHeight());
            params.setMargins(x, y, 0, 0);
            videoGroup.setLayoutParams(params);
            Animation animationa = new ViewSizeChangeAnimation(videoGroup, mScreenHeight + ConvertUtils.dp2px(25f), mScreenWidth, x, y);
            animationa.setDuration(300);
            videoGroup.startAnimation(animationa);

            animationa.setAnimationListener(new Animation.AnimationListener() {
                //动画开始的时候触发
                @Override
                public void onAnimationStart(Animation animation) {

                }

                //动画结束的时候触发
                @Override
                public void onAnimationEnd(Animation animation) {

                    videoGroup.setClickable(true);
                }

                //动画重新执行的时候触发
                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
            mCurContainer.bringToFront();
            videoGroup.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //缩小视频
                    if (ClickUtil.canClick(600)) {
                        viewGroup = (ViewGroup) videoGroup.getParent();
                        if (viewGroup != null) {
                            viewGroup.removeView(videoGroup);

                        }
                        img.setVisibility(View.VISIBLE);
                        mPlayer.stopPlay(true);
                        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) videoGroup.getLayoutParams();
                        params.width = container.getWidth();
                        params.height = container.getHeight();
                        params.setMargins(0, 0, 0, 0);
                        videoGroup.setLayoutParams(params);

                        FrameLayout.LayoutParams sv = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
                        sv.width = container.getWidth();
                        sv.height = container.getHeight();
                        mVideoView.setLayoutParams(sv);
                        mCurContainer.setClickable(false);
                        container.addView(videoGroup);
                        videoGroup.setClickable(false);
                        isOnclick = false;
                    }

                }
            });
        }
        return container;
    }

    /**
     * 设置视频缩放的大小
     *
     * @param w          后台拿到视频的宽高
     * @param h
     * @param mVideoView 计算方法我写不出来 不建议改
     */
    public void resizeVideo(int w, int h, TXCloudVideoView mVideoView) {//放大后给视频加背景
        if (w == 0 || h == 0) {
            //      ToastUtil.show("视频无法放大");
            return;
        }
        BigDecimal mVideoWidth = new BigDecimal(w + "");
        BigDecimal mVideoHeight = new BigDecimal(h + "");
        KLog.e("tag", "屏幕的宽高" + mScreenWidth + "/" + mScreenHeight + "视频的宽高" + w + "/" + h);
        boolean istransverse;
        if (mVideoWidth.compareTo(mVideoHeight) == 1) {
            istransverse = true;
        } else {
            istransverse = false;
        }
        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
        if (istransverse) {//如果横屏
            if (mVideoWidth.compareTo(new BigDecimal(mScreenWidth + "")) == 1) {  //如果视频的宽度大于屏幕的快读
                BigDecimal a = mVideoWidth.subtract(new BigDecimal(mScreenWidth + ""));
                BigDecimal b = a.divide(new BigDecimal(mVideoWidth + ""), 2, BigDecimal.ROUND_UP);
                BigDecimal c = b.multiply(new BigDecimal(mVideoHeight + ""));
                BigDecimal d = new BigDecimal(mVideoHeight + "").subtract(c);
                params.width = mScreenWidth;
                params.height = d.intValue();
            } else {
                BigDecimal a = new BigDecimal(mScreenWidth + "").subtract(mVideoWidth);
                BigDecimal b = a.divide(new BigDecimal(mVideoWidth + ""), 2, BigDecimal.ROUND_DOWN);
                BigDecimal c = b.multiply(new BigDecimal(mVideoHeight + ""));
                BigDecimal d = new BigDecimal(mVideoHeight + "").add(c);
                params.width = mScreenWidth;
                params.height = d.intValue();
            }

        } else {
            if (mVideoHeight.compareTo(new BigDecimal(mScreenHeight + "")) == 1) {
                BigDecimal a = mVideoHeight.subtract(new BigDecimal(mScreenHeight + ""));
                BigDecimal b = a.divide(new BigDecimal(mVideoHeight + ""), 2, BigDecimal.ROUND_UP);
                BigDecimal c = b.multiply(new BigDecimal(mVideoWidth + ""));
                BigDecimal d = new BigDecimal(mVideoWidth + "").subtract(c);
                params.width = d.intValue();
                params.height = mScreenHeight;
            } else {
                BigDecimal a = new BigDecimal(mScreenHeight + "").subtract(mVideoHeight);
                BigDecimal b = a.divide(new BigDecimal(mVideoHeight + ""), 2, BigDecimal.ROUND_UP);
                BigDecimal c = b.multiply(new BigDecimal(mVideoWidth + ""));
                BigDecimal d = new BigDecimal(mVideoWidth + "").add(c);
                params.width = d.intValue();
                params.height = mScreenHeight;
            }


        }
        params.gravity = Gravity.CENTER;
        mVideoView.setLayoutParams(params);
    }

    //点击返回键 如果视频放大先返回
    public void videoBacks() {
        if (isOnclick) {
            try {
                viewGroup = (ViewGroup) myVideGroup.getParent();
                if (viewGroup != null) {
                    viewGroup.removeView(myVideGroup);

                }
                if (null != mVideoView) {
                    FrameLayout.LayoutParams sv = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
                    sv.width = mOriginContainer.getWidth();
                    sv.height = mOriginContainer.getHeight();
                    mVideoView.setLayoutParams(sv);
                }
                mPlayer.stopPlay(true);
                FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) myVideGroup.getLayoutParams();
                params.width = mOriginContainer.getWidth();
                params.height = mOriginContainer.getHeight();
                myVideGroup.setLayoutParams(params);
                mCurContainer.setClickable(false);
                mOriginContainer.addView(myVideGroup);
                myVideGroup.setClickable(false);
            } catch (NullPointerException e) {

            }
        }
    }

    //返回时是否要先返回大视频
    public boolean isBackVideo() {
        return mCurContainer.getChildCount() > 0;
    }

    public boolean isBackVideos() {
        return mCurContainer.getChildCount() > 1;
    }

    public boolean isBackVideoss() {
        return mCurContainer.getChildCount() > 2;
    }

    public void videoBack() {
        if (mCurContainer.getChildCount() > 0) {
            if (null != viewGroup) {
                viewGroup = (ViewGroup) myVideGroup.getParent();
            }

            if (viewGroup != null) {
                viewGroup.removeView(myVideGroup);

            }
            mCurContainer.setClickable(false);
            mOriginContainer.addView(myVideGroup);
            myVideGroup.setClickable(false);
            if (null != mPlayView) {
                mPlayView.setVideoSize(false);
            }


            //            mCurContainer.setClickable(false);
            //            if (mPlayView != null) {
            //                mPlayView.pausePlay();
            //            }
            //            View playGroup = mCurContainer.getChildAt(0);
            //       //     mCurContainer.removeView(playGroup);
            //            if (mOriginContainer != null) {
            //    //            mOriginContainer.addView(playGroup);
            //                if (mPlayView != null) {
            //                    mPlayView.setVideoSize(false);
            //                    mPlayView.resizeVideo(false);
            //                    mPlayView.resumePlay();
            //                }
            //            }
        }
    }


    //列表播语音时的回调
    public void setVoicePlayCallBack(VoicePlayCallBack voicePlayCallBack) {
        mVoicePlayCallBack = voicePlayCallBack;
    }

    /**
     * 语音
     *
     * @param length      时长
     * @param tvVoiceTime 显示时长的
     */
    public void setVoiceInfo(int length, TextView tvVoiceTime) {
        mSumVoiceTime = length;
        mPlayVoiceTime = length;
        mTvVoiceTime = tvVoiceTime;
    }

    /**
     * 播放语音
     */
    public void playVoice(String voiceLink) {
        if (TextUtils.isEmpty(voiceLink)) {
            return;
        }
        String fileName = MD5Util.getMD5(voiceLink);
        String path = CommonAppConfig.VOICE_PATH + fileName;
        File file = new File(path);
        if (file.exists()) {
            playVoiceFile(file);
        } else {
            if (mDownloadUtil == null) {
                mDownloadUtil = new DownloadUtil();
            }
            mDownloadUtil.download("voice", CommonAppConfig.VOICE_PATH, fileName, voiceLink, new DownloadUtil.Callback() {
                @Override
                public void onSuccess(File file) {
                    playVoiceFile(file);
                }

                @Override
                public void onProgress(int progress) {

                }

                @Override
                public void onError(Throwable e) {
                    ToastUtil.show(WordUtil.getString(R.string.video_play_error));
                    if (mVoicePlayCallBack != null) {
                        mVoicePlayCallBack.onPlayAutoEnd();
                    }
                }
            });
        }
    }

    /**
     * 停止播放语音
     */
    public void stopVoice() {
        if (mVoiceMediaPlayerUtil != null) {
            mVoiceMediaPlayerUtil.stopPlay();
        }
        if (mPlayView != null) {
            mPlayView.setMute(false);
        }
        if (mHandler != null) {
            mHandler.removeMessages(0);
        }
        if (mVoicePlayCallBack != null) {
            mVoicePlayCallBack.onPlayEnd();
        }
        mPlayVoiceTime = mSumVoiceTime;
        if (mTvVoiceTime != null) {
            mTvVoiceTime.setText(mPlayVoiceTime + "s");
        }
    }

    /**
     * 语音暂停
     */
    public void pauseVoice() {
        if (mVoiceMediaPlayerUtil != null) {
            if (mVoiceMediaPlayerUtil.isStarted()) {
                mVoiceMediaPlayerUtil.pausePlay();
                if (mPlayView != null) {
                    mPlayView.setMute(false);
                }
                if (mVoicePlayCallBack != null) {
                    mVoicePlayCallBack.onPlayPause();
                }
            }
        }
        if (mHandler != null) {
            mHandler.removeMessages(0);
        }
    }


    // 语音继续播
    public void resumeVoice(String path) {
        if (mVoiceMediaPlayerUtil == null) {
            return;
        }
        if (mVoiceMediaPlayerUtil.isPaused()) {
            mVoiceMediaPlayerUtil.resumePlay();
        } else {
            mVoiceMediaPlayerUtil.startPlay(path);
        }
        if (mHandler != null) {
            mHandler.sendEmptyMessageDelayed(0, 1000);
        }
        if (mVoicePlayCallBack != null) {
            mVoicePlayCallBack.onPlayResume();
        }

    }


    // 播语音
    @SuppressLint("HandlerLeak")
    private void playVoiceFile(File file) {
        if (mPlayView != null) {
            mPlayView.setMute(true);
        }
        if (mHandler == null) {
            mHandler = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                    super.handleMessage(msg);
                    mPlayVoiceTime--;
                    if (mPlayVoiceTime > 0) {
                        if (mHandler != null) {
                            mHandler.sendEmptyMessageDelayed(0, 1000);
                        }
                        if (mTvVoiceTime != null) {
                            mTvVoiceTime.setText(mPlayVoiceTime + "s");
                        }
                    } else {
                        mPlayVoiceTime = mSumVoiceTime;
                    }
                }
            };
        }
        if (mVoiceMediaPlayerUtil == null) {
            mVoiceMediaPlayerUtil = new VoiceMediaPlayerUtil(mContext);
            mVoiceMediaPlayerUtil.setActionListener(new VoiceMediaPlayerUtil.ActionListener() {
                @Override
                public void onPlayEnd() {
                    L.e("---show-onPlayAutoEnd-");
                    mPlayVoiceTime = mSumVoiceTime;
                    if (mTvVoiceTime != null) {
                        mTvVoiceTime.setText(mPlayVoiceTime + "s");
                    }
                    if (mHandler != null) {
                        mHandler.removeMessages(0);
                    }
                    if (mPlayView != null) {
                        mPlayView.setMute(false);
                    }
                    if (mVoicePlayCallBack != null) {
                        mVoicePlayCallBack.onPlayAutoEnd();
                    }
                }
            });
        }
        mVoiceMediaPlayerUtil.startPlay(file.getAbsolutePath());
        if (mHandler != null) {
            mHandler.sendEmptyMessageDelayed(0, 1000);
        }
        if (mVoicePlayCallBack != null) {
            mVoicePlayCallBack.onPlayStart();
        }
        if (mTvVoiceTime != null) {
            mTvVoiceTime.setText(mSumVoiceTime + "s");
        }
    }

    /**
     * 播语音的时候设置视频静音
     */
    public void setMute(boolean mute) {
        if (mPlayView != null) {
            mPlayView.setMute(mute);
        }
    }

    /**
     * 社区举报和取消
     */
    private PopupWindow mPopWindow;
    private RecyclerView mRecyclerView;
    private NewCirclePopAdapter mAdapter;

    public void showpop(final View m_view, List<String> arrayList, final String id) {
        View contentView = LayoutInflater.from(mContext).inflate(R.layout.dialog_pop_new_circle, null);
        mPopWindow = new PopupWindow(contentView,
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
        mPopWindow.setContentView(contentView);
        mRecyclerView = contentView.findViewById(R.id.rv_newlistview);
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL));
        mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
        mAdapter = new NewCirclePopAdapter(R.layout.rv_new_circle_item, arrayList);
        mRecyclerView.setAdapter(mAdapter);
        if (mPopWindow.isShowing()) {
            mPopWindow.dismiss();
        } else {
            mPopWindow.showAsDropDown(m_view);
        }
        mAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                if (position == 0) {
                    RouteUtil.forwardReport(2, id);
                    //DynamicReportActivity.forward(AbsDynamicActivity.this, id);
                }


                mPopWindow.dismiss();
            }
        });


    }

    @Override
    protected void onPause() {
        super.onPause();
        pauseVoice();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mVoiceMediaPlayerUtil != null) {
            mVoiceMediaPlayerUtil.destroy();
        }
        DynamicHttpUtil.cancel(DynamicHttpConsts.DYNAMIC_ADDLIKE);
        DynamicHttpUtil.cancel(DynamicHttpConsts.DYNAMIC_DEL);
    }

}
